let obj = {
    name: "Hydra",
    age: 35,
    [Symbol.for("sayHello")]() {
        console.log("Hello")
    },
    frined: {
        name: "刘煜鑫",
        age: 24,
        friend: {
            name: "李佳彤",
            age: 20,
        }
    }
}

/**
 * 对对象进行深拷贝
 * @param {Object} obj 
 */
function deepClone(obj) {
    let keys = Object.keys(obj);
    // symbol属性也可以拷贝
    let symbolKeys = Object.getOwnPropertySymbols(obj);
    keys.push(...symbolKeys);

    let newObj = {};
    for (let key of keys) {
        let value = obj[key];
        // 如果是对象
        if (typeof value == 'object') {
            newObj[key] = deepClone(value);
        // 普通属性
        } else {
            newObj[key] = value;
        }
    }
    return newObj;
}

let newObj = deepClone(obj);
obj.frined.name = "张三";

newObj[Symbol.for("sayHello")]()